﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Pozr
{
    public partial class ControlStatus : UserControl
    {
        public ControlStatus()
        {
            InitializeComponent();
            aibExit.BackgroundImage = CustomControls.AlphaImage.CreateFromResource("Pozr.Resources.exit_button.png");
            aibExit.ActiveBackgroundImage = CustomControls.AlphaImage.CreateFromResource("Pozr.Resources.exit_button_active.png");
            aibMinimize.BackgroundImage = CustomControls.AlphaImage.CreateFromResource("Pozr.Resources.min_button.png");
            aibMinimize.ActiveBackgroundImage = CustomControls.AlphaImage.CreateFromResource("Pozr.Resources.min_button_active.png");
        }

        protected override void OnResize(EventArgs e)
        {
            Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
            
            Graphics g = Graphics.FromImage(bmp);
           
    //        g.Clear(Color.Gray);
    //        Microsoft.Drawing.GradientFill.Fill(g, new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height), Color.Black, Color.FromArgb(80, 80, 80), Microsoft.Drawing.FillDirection.TopToBottom);

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
            this.apbBackground.Image = CustomControls.AlphaImage.CreateFromStream(stream);
            aibMinimize.Top = 0;
            aibMinimize.Left = this.ClientSize.Width - this.aibMinimize.ClientSize.Width;
            aibExit.Top = 0;
            aibExit.Left = this.ClientSize.Width - this.aibMinimize.ClientSize.Width - this.aibExit.ClientSize.Width;

            g.Dispose();
            bmp.Dispose();

            this.Refresh();
            base.OnResize(e);
        }

        private void aibExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void aibMinimize_Click(object sender, EventArgs e)
        {
            Middleware.Sleep();
        }
    }
}
